dnl 
dnl configure.ac for sector_decomposition
dnl
dnl written by Stefan Weinzierl
dnl
dnl Process this file with autoconf to produce a configure script

AC_INIT(sector_decomposition/sector_decomposition.h)

SECTOR_DECOMPOSITION_MAJOR=1
SECTOR_DECOMPOSITION_MINOR=1
SECTOR_DECOMPOSITION_MICRO=0

SECTOR_DECOMPOSITION_VERSION=$SECTOR_DECOMPOSITION_MAJOR.$SECTOR_DECOMPOSITION_MINOR.$SECTOR_DECOMPOSITION_MICRO

SECTOR_DECOMPOSITION_CURRENT=0
SECTOR_DECOMPOSITION_REVISION=0
SECTOR_DECOMPOSITION_AGE=0

SECTOR_DECOMPOSITION_LIBVERSION=$SECTOR_DECOMPOSITION_CURRENT:$SECTOR_DECOMPOSITION_REVISION:$SECTOR_DECOMPOSITION_AGE

AC_SUBST(SECTOR_DECOMPOSITION_MAJOR)
AC_SUBST(SECTOR_DECOMPOSITION_MINOR)
AC_SUBST(SECTOR_DECOMPOSITION_MICRO)
AC_SUBST(SECTOR_DECOMPOSITION_VERSION)
AC_SUBST(SECTOR_DECOMPOSITION_CURRENT)
AC_SUBST(SECTOR_DECOMPOSITION_REVISION)
AC_SUBST(SECTOR_DECOMPOSITION_AGE)
AC_SUBST(SECTOR_DECOMPOSITION_LIBVERSION)

dnl define the dependencies of the current version
GINACVERSION=1.3.0
GSLVERSION=1.2

AC_SUBST(GINACVERSION)
AC_SUBST(GSLVERSION)

dnl This defines PACKAGE and VERSION.
AM_CONFIG_HEADER(config.h)

AM_INIT_AUTOMAKE(sector_decomposition,$SECTOR_DECOMPOSITION_VERSION)

dnl check the C compiler
AC_PROG_CC

dnl check the C++ compiler
AC_PROG_CXX
AC_PROG_CXXCPP

dnl check the install program
AC_PROG_INSTALL

dnl check libtool
AC_PROG_LIBTOOL

dnl switch to C++
AC_LANG_CPLUSPLUS

dnl ----------------------------------------
dnl check libraries

dnl need the dynamic loader library in the Monte Carlo integration
AC_CHECK_LIB(dl,dlopen,
             [
              DL_LIBS="-ldl"
              AC_SUBST(DL_LIBS)
              AC_DEFINE(HAVE_LIBDL, 1, [Define to 1 if you have the `dl' library (-ldl).])
             ], 
             AC_MSG_ERROR(need to have the `dl' library installed.))


dnl GiNaC
dnl this defines GINACLIB_CPPFLAGS and GINACLIB_LIBS
dnl old macro:
dnl
dnl AM_PATH_GINAC($GINACVERSION, [], AC_MSG_ERROR([need to have at least GiNaC $GINACVERSION installed]))
dnl
dnl new macro:
dnl
PKG_CHECK_MODULES(GINACLIB, ginac >= $GINACVERSION, [], AC_MSG_ERROR([need to have at least GiNaC $GINACVERSION installed]))
GINACLIB_CPPFLAGS=$GINACLIB_CFLAGS
AC_SUBST(GINACLIB_CPPFLAGS)


dnl GNU scientific library
dnl this defines GSL_CFLAGS and GSL_LIBS
AM_PATH_GSL($GSLVERSION, 
            AC_DEFINE(HAVE_GSL, 1, [Define to 1 if gsl is installed.]), 
            AC_MSG_ERROR([need to have at least GNU scientific library $GSLVERSION installed]))


dnl Expand the cppflags and libraries needed by apps using sector_decomposition
SECTOR_DECOMPOSITIONLIB_CPPFLAGS="$CPPFLAGS $GINACLIB_CPPFLAGS $GSL_CFLAGS"
SECTOR_DECOMPOSITIONLIB_LIBS="$LIBS $GINACLIB_LIBS $GSL_LIBS"
AC_SUBST(SECTOR_DECOMPOSITIONLIB_CPPFLAGS)
AC_SUBST(SECTOR_DECOMPOSITIONLIB_LIBS)

dnl ----------------------------------------
dnl testsuite

AC_ARG_WITH(checks,
            [  --with-checks           testsuite],
            [case "${withval}" in
              yes) have_checks=true ;;
              no) have_checks=false ;;
              *) AC_MSG_ERROR(bad value ${withval} for --with-checks) ;;
             esac],[have_checks=false])

AM_CONDITIONAL(CHECKS, test x$have_checks = xtrue)

dnl ----------------------------------------
AC_OUTPUT(Makefile sector_decomposition-config 
          sector_decomposition/Makefile 
          sector_decomposition/sector_decomposition.h
          sector_decomposition/compile_sector_decomposition
          checks/Makefile)

